"use strict";
const path = require("path");
const webpack = require("webpack");

function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  publicPath: "/",

  devServer: {
    open: true,
    port: 5051,
    overlay: false,
  },

  css: {
    loaderOptions: {
      less: {
        modifyVars: {
          "text-color": "#262626"
        },
        javascriptEnabled: true
      }
    }
  },

  chainWebpack: config => {
    config.plugin("define").tap(args => {
      args[0] = {
        "process.env":
          process.env.ENV === "prod"
            ? require("./config/prod.env")
            : require("./config/dev.env")
      };

      return args;
    });
  },

  configureWebpack: {
    plugins: [new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)],
    resolve: {
      // alias: {
      //   "@ant-design/icons/lib/dist$": resolve("src/icons.js")
      // }
    }
  },

  pluginOptions: {
    // https://www.npmjs.com/package/vue-cli-plugin-style-resources-loader
    "style-resources-loader": {
      preProcessor: "less",
      patterns: [
        resolve("src/styles/var.less"),
        resolve("src/styles/mixins.less")
      ]
    }
  }
};
